package com.bean;

import java.util.Objects;

public class Admin {
    /**
     * 用户编号
     */
    private Integer id;
    private String no;
    /**
     * 用户名
     */
    private String name;
    /**
     * 用户密码
     */
    private String password;
    /**
     * 用户头像
     */
    private String headPic;
    /**
     * 职位编号
     */
    private Integer roleId;

    private String roleName;

    private String sex;

    private Integer age;

    private String email;

    private String phone;

    public Admin() {
    }

    public Admin(String name, String no, String password, String headPic, Integer roleId, Integer sex, Integer age, String email, String phone) {
        this.name = name;
        this.no = no;
        this.password = password;
        this.headPic = headPic;
        this.roleId = roleId;
        this.sex = (sex == 0 ? "男" : "女");
        this.age = age;
        this.email = email;
        this.phone = phone;
    }

    public Admin(String no, String password) {
        this.no = no;
        this.password = password;
    }

    @Override
    public String toString() {
        return "Admin{" +
                "id=" + id +
                ", no='" + no + '\'' +
                ", name='" + name + '\'' +
                ", password='" + password + '\'' +
                ", headPic='" + headPic + '\'' +
                ", roleId=" + roleId +
                ", roleName='" + roleName + '\'' +
                ", sex='" + sex + '\'' +
                ", age=" + age +
                ", email='" + email + '\'' +
                ", phone='" + phone + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Admin admin = (Admin) o;
        return Objects.equals(no, admin.no) &&
                Objects.equals(password, admin.password);
    }

    @Override
    public int hashCode() {
        return Objects.hash(no, password);
    }

    public String getNo() {
        return no;
    }

    public void setNo(String no) {
        this.no = no;
    }

    public String getRoleName() {
        return roleName;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getHeadPic() {
        return headPic;
    }

    public void setHeadPic(String headPic) {
        this.headPic = headPic;
    }

    public Integer getRoleId() {
        return roleId;
    }

    public void setRoleId(Integer roleId) {
        this.roleId = roleId;
    }

    public Integer getSex() {
        Integer sexInt = null;
        if (sex == "男") {
            sexInt = 0;
        } else if (sex == "女") {
            sexInt = 1;
        }
        return sexInt;
    }

    public void setSex(Integer sex) {
        if (sex == 0) {
            this.sex = "男";
        } else if (sex == 1) {
            this.sex = "女";
        } else {
            this.sex = null;
        }
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }
}